package com.spacearcade.common.layers.commands;

import java.util.Collections;
import java.util.Map;

public class CommandRequest {

	private final CommandType type;
	private final Map<String, String> parameters;
	private final String targetID;

	public static CommandRequest newDeleteCommand(String objectId) {
		return new CommandRequest(CommandType.DeleteObject,
				Collections.EMPTY_MAP, objectId);
	}

	public static CommandRequest newCreateCommand(Map<String, String> initProperties) {
		return new CommandRequest(CommandType.CreateObject, initProperties, null);
	}

	public static CommandRequest newChangeCommand(String objectId,
			Map<String, String> params) {
		return new CommandRequest(CommandType.PropertySet, params, objectId);
	}

	private CommandRequest(CommandType type, Map<String, String> params,
			String targerID) {
		this.type = type;
		this.parameters = params;
		this.targetID = targerID;
	}

	public String getTargetID() {
		return targetID;
	}

	public CommandType getType() {
		return type;
	}

	public String getParameter(String key) {
		return parameters.get(key);
	}

	public Map<String, String> getParameters() {
		return parameters;
	}
}
